from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from goods.models import SPUSpecification
from meiduo_admin.serlizer.specs import SpecsSerializer, SPUSerializer
from meiduo_admin.utils import PageNum
from goods.models import SPU

class SpecsView(ModelViewSet):
    '''商品规格增删改查'''

    # 指定查询集
    queryset = SPUSpecification.objects.all()
    # 指定序列化器
    serializer_class = SpecsSerializer
    # 指定分页
    pagination_class = PageNum

    def simple(self, request):
        '''获取spu商品'''

        spus = SPU.objects.all()
        ser = SPUSerializer(spus, many=True)

        return Response(ser.data)